package com.nbsaas.boot.wms.rest.convert;

import com.nbsaas.boot.wms.data.entity.WarehouseCatalog;
import com.nbsaas.boot.wms.api.domain.response.WarehouseCatalogResponse;

import com.nbsaas.boot.utils.BeanDataUtils;
import com.nbsaas.boot.rest.api.Converter;

/**
 * 仓库-实体对象转化成响应对象
 */

public class WarehouseCatalogResponseConvert implements Converter<WarehouseCatalogResponse, WarehouseCatalog> {

    @Override
    public WarehouseCatalogResponse convert(WarehouseCatalog source) {
        WarehouseCatalogResponse result = new WarehouseCatalogResponse();
        BeanDataUtils.copyProperties(source, result);
        if (source.getParent() != null) {
            result.setParent(source.getParent().getId());
        }

        try {
            if (source.getParent() != null) {
                result.setParentName(source.getParent().getName());
            }
        } catch (Exception ignored) {
        }

        return result;
    }

}

